package com.example.demo1104.demo3;

import java.util.ArrayList;
import java.util.Collections;

public class Test {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"小猪","小李","马云","马化腾","王健林");

        ArrayList<String> str = new ArrayList<>();
        for (String a:list){
            if (a.startsWith("小")) {
                str.add(a);
            }
        }
        System.out.println(str);
        ArrayList<String> str2 = new ArrayList<>();
        for (String a:str){
            if (a.length()==2) {
                str2.add(a);
            }
        }

        System.out.println(list);
        System.out.println(str2);



    }
}
